package com.qingke.demo.account;

public class Account {
	private String id;
	private String name;
	private int balance =0;
	
	public Account(String id,String name){
		this.id = id;
		this.name = name;
	}
	
	public Account(String id,String name,int balance){
		this.id = id;
		this.name = name;
		this.balance = balance;
	}
	
	public String getID(){
		return id;
	}
	
	public String getName(){
		return name;
	}
	
	public int getBalance(){
		return balance;
	}
	
	public int credit(int amount){
		return amount+balance;
	}
	
	public int debit(int amount){
		if(amount<=balance)
			return balance-amount;
		else
			System.out.println("Amount exceeded balance");
		
		return balance;
	}
	
	public int transferTo(Account another,int amount){
		if(amount<=balance)
			return another.balance +amount;
		else
			System.out.println("Amount exceeded balance");
		return balance;
	}
	
	public String toString(){
		return "Account[id="+id+",name="+name+",balance="+balance+"]";
	}
	
	
	
	
	public static void main(String[] args){
		Account a =new Account("123","Mike",1500);
		System.out.println(a.credit(1000));
		System.out.println(a.debit(1600));
		Account b = new Account("234","Ben",1600);
		System.out.println(b.transferTo(b, 2000));
	}
}
